package com.itlong.cloud.propertyapp.resource;

import com.itlong.cloud.POJO.DTO.app.property.app.PropertyAppAlarmDTO;
import com.itlong.cloud.POJO.DTO.app.property.app.PropertyAppInspectDTO;
import com.itlong.cloud.POJO.PO.PropertyInspectPointInfoPO;
import com.itlong.cloud.POJO.PO.PropertyInspectRecordPO;
import com.itlong.cloud.POJO.VO.app.property.app.PropertyAppInspectLineInfoVO;
import com.itlong.cloud.POJO.VO.app.property.app.PropertyAppInspectRecordDetailVO;
import com.itlong.cloud.POJO.VO.app.property.app.PropertyAppInspectInfoVO;
import com.itlong.cloud.inspect.IPropertyAppInspectServiceClient;
import com.itlong.cloud.propertyapp.service.IPropertyAppInspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      物业APP巡检暴露接口实现类
 * </desc>
 *
 * @createDate2020/1/7
 **/
@RestController
public class PropertyAppInspectServiceResource implements IPropertyAppInspectServiceClient {

    @Autowired
    private IPropertyAppInspectService iPropertyAppInspectService;

    /**
    *      物业app查询巡检计划列表
    * </desc>
    *
    * @param
    * @return
    * @Author Zhu.yj
    * @createDate  2020/1/6
    */
    @Override
    @PostMapping("/home/getInspectPlanList")
    public List<PropertyAppInspectInfoVO> getInspectPlanList(@RequestParam("userId") String userId, @RequestParam("projectId") String projectId) throws Exception {
        return iPropertyAppInspectService.getInspectPlanList(userId, projectId);
    }

    /**
     * <desc>
     *      保存报警信息
     * </desc>
     *
     * @param propertyAppAlarmDTO 物业app报警DTO
     * @return
     * @Author Zhu.yj
     * @createDate  2020/1/7
     */
    @Override
    @PostMapping("/home/savePoliceCallDetail")
    public Integer savePoliceCallDetail(@RequestBody PropertyAppAlarmDTO propertyAppAlarmDTO) throws Exception{
        return iPropertyAppInspectService.savePoliceCallDetail(propertyAppAlarmDTO);
    }

    /**
     * <desc>
     *      根据巡检点编号获取巡检点信息
     * </desc>
     *
     * @return 巡检点信息
     * @author wangzhi
     * @createDate 2020/01/08
     */
    @Override
    @PostMapping("/home/getInspectPointByNum")
    public PropertyInspectPointInfoPO getInspectPointByNum(@RequestBody PropertyAppInspectDTO propertyAppInspectDTO) throws Exception {
        return iPropertyAppInspectService.getInspectPointByNum(propertyAppInspectDTO);
    }

    /**
     * <desc>
     *      保存巡检详情
     * </desc>
     *
     * @return 受影响行数
     * @author wangzhi
     * @createDate 2020/01/08
     */
    @Override
    @PostMapping("/home/saveInspectRecord")
    public Integer saveInspectRecord(@RequestBody PropertyInspectRecordPO propertyInspectRecordPO) throws Exception {
        return iPropertyAppInspectService.saveInspectRecord(propertyInspectRecordPO);
    }

    /**
     * <desc>
     *      查询巡检记录月视图时间
     * </desc>
     *
     * @return 年月和其对应的日期列表
     * @author wangzhi
     * @createDate 2020/02/17
     */
    @Override
    @PostMapping("/home/getInspectRecordTime")
    public List<Map<String, Object>> getInspectRecordTime(@RequestBody PropertyAppInspectDTO propertyAppInspectDTO) throws Exception {
        return iPropertyAppInspectService.getInspectRecordTime(propertyAppInspectDTO);
    }

    /**
     * <desc>
     *      查询巡检记录月视图详情
     * </desc>
     *
     * @return 巡检记录月视图详情
     * @author wangzhi
     * @createDate 2020/02/17
     */
    @Override
    @PostMapping("/home/getInspectRecordDetail")
    public List<PropertyAppInspectRecordDetailVO> getInspectRecordDetail(@RequestBody PropertyAppInspectDTO propertyAppInspectDTO) throws Exception {
        return iPropertyAppInspectService.getInspectRecordDetail(propertyAppInspectDTO);
    }

    /**
     * <desc>
     *      获取巡检计划列表
     * </desc>
     *
     * @param inspectPlanId 巡检计划id
     * @param projectId 项目id
     * @param pageNum  页码
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/2
     */
    @Override
    @PostMapping("/home/getInspectLineList")
    public List<PropertyAppInspectLineInfoVO> getInspectLineList(@RequestParam("inspectPlanId") String inspectPlanId,
                                                                 @RequestParam("projectId") String projectId,
                                                                 @RequestParam("pageNum") String pageNum) throws Exception {
        return iPropertyAppInspectService.getInspectLineList(inspectPlanId, projectId, pageNum);
    }

    /**
     * <desc>
     *      获取巡检点列表信息
     * </desc>
     *
     * @param inspectPlanId 巡检计划id
     * @param projectId 项目id
     * @param pageNum  页码
     * @return
     * @Author Zhu.yj
     * @createDate  2020/4/2
     */
    @Override
    @PostMapping("/home/getInspectPointList")
    public List<String> getInspectPointList(@RequestParam("inspectPlanId") String inspectPlanId,
                                            @RequestParam("projectId") String projectId,
                                            @RequestParam("pageNum") String pageNum) throws Exception {
        return iPropertyAppInspectService.getInspectPointList(inspectPlanId, projectId, pageNum);
    }
}
